var ani = (function() {
  var aniList = [
    document.querySelector('.product'),
    document.querySelector('.core'),
    document.querySelector('.contact'),
    document.querySelector('.partner'),
  ]

  ScrollReveal().reveal(aniList, {
    distance: '150px',
    during: 600,
    easing: 'ease',
    origin: 'bottom',
    reset: true,
    delay: 300
  })

  ScrollReveal().reveal(document.querySelector('.kv'), {
    during: 300,
    easing: 'ease',
    reset: true,
  })


  var ParallaxList = ['.kv', '.core-list', '.partner-list', '.product-list', '.contact-list'];

  for (var i = 0, len = ParallaxList.length; i < len; i++) {
    new Parallax(document.querySelector(ParallaxList[i]), {
      relativeInput: true
    });
  }

})();

var kv = (function() {
  var oNext = document.querySelector('.kv-next');

  var toNextPage = function() {
    this.scrollIntoView({
      block: "start",
      behavior: 'smooth'
    })
  }

  oNext.addEventListener('click', toNextPage)
})()

var product = (function() {
  var sw = function() {
    var slide = new Swiper('.product-wrap', {
      slidesPerView: 'auto',
      slidesPerGroup: 2,
      initialSlide: 0,
      //autoplay: 3000,
      prevButton: '.product-prev',
      nextButton: '.product-next',
      observer: true,
      observeParents: true,
    })
  }

  createList('#product', sw)
})()

var map = (function() {
  var map = new BMap.Map("contact-map");
  var pointA = new BMap.Point(113.948888,22.556365);
  map.centerAndZoom(pointA, 16);
  map.addControl(new BMap.NavigationControl());
  map.addControl(new BMap.ScaleControl());
  map.addControl(new BMap.OverviewMapControl());

  // 创建标注1
  addMarker(pointA, "深圳市微聚科技有限公司", "地址：深圳市南山区高新中一道长园新材料港10栋706<br/>电话：0755-88359812");

  function addMarker(point, a, b) {
    var marker = new BMap.Marker(point);
    map.addOverlay(marker);
    marker.setAnimation(BMAP_ANIMATION_BOUNCE);
  }
})()

new Vue({
  el: '#partner',
  data() {
    return {
      uploadUrl: HTTP_URL.server.upload_uri,
      params: {
          projectId: 1,
          partnerId: 5,
          pageNum: 1,
          pageSize: 3,
      },
      partnerList: [],
    }
  },
  created() {
    this.setPartnerData();
  },
  methods: {
    setPartnerData() {
      $.ajax({
          url:HTTP_URL.server.data_api_uri + '/v1/data/list',
          type: 'get',
          data: {
              projectId: this.params.projectId,
              templateId: this.params.partnerId,
              pageNum: this.params.pageNum,
              pageSize: this.params.pageSize
          }
      }).then(res => {
        this.partnerList = res.data.page.data;
      })
    },
  }
})